<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class Research extends CCMIS_Controller{
    public function __construct() {
        parent::__construct();
        $this->load->model('rmis/mdl_rmis_research', 'mdl_rms');
    }

    public function index()
    {
    	$this->research();
    }

    public function research()
    {
    	$data = array(
            'page_title' => 'RMIS | Research',
            'msg' => '',
        );

        $Res_ID = $this->mdl_rms->get_research_details();

        if($Res_ID == 0){
            $data['msg'] = 'No researches available';
        } else {
            $i = 0;
            foreach ($Res_ID as $paper) {
                $auth[$i] = $this->mdl_rms->get_research_authors($paper['Res_ID']);
                $i++;
            }

            $i = 0;
            foreach ($Res_ID as $det) {
                $data['paper'][$i] = $det;
                $i++;
            }

            $i = 0;
            foreach ($auth as $det) {
                $data['auth'][$i] = $det[0];
                $i++;
            }            
        }

    	$this->setup_view('rmis/research/research', $data);
    }

    public function viewresearch($ID){
        $data = array(
            'page_title' => 'RMIS | Research',
            'msg' => '',
        );

        $data['paper'] = $this->mdl_rms->get_reserch_details($ID);
        $data['auth'] = $this->mdl_rms->get_research_authors($ID);
        $data['field'] = $this->mdl_rms->get_research_field($data['paper'][0]['Fid_ID']);

        $this->setup_view('rmis/research/researchContent', $data);
    }
}
?>
